<?php
$feedUrl = "";
$title = "";

if(isset($_GET["torrentfeed"])) {
	$torrentfeedContent = @file_get_contents($_GET["torrentfeed"]);
	
	// find the title
	preg_match("#<title>(.*)</title>#U", $torrentfeedContent, $match);
	$title = @$match[1];
	
	// try to find the tag with rel="self"
	$pattern = "#(<.*rel=\"self\".*>)#U";
	if(preg_match($pattern, $torrentfeedContent, $match)) {
		
		// separate url
		preg_match("#href=\"(.*)\"#U", $match[1], $match);
		$feedUrl = @$match[1];
	}
}

$title = urldecode($title);
$feedUrl = urldecode($feedUrl);

echo "{title:$title:}{feedUrl:$feedUrl:}";
?>